"use strict";
/*
import axios from 'axios';
import {btoa, atob} from 'Base64';
import Url from './Url';

export default (function () {
  const contextPath = '..';

  /!**
   * 把一个url拼接成相对于网站根路径的方法，类似spring:url，只处理"/"打头的相对路径
   * @param raw 原始Url
   * @returns string
   *!/
  function fullUrl(raw) {
    if (!contextPath || contextPath.length === 0 || contextPath === "/") {
      return raw;
    }
    if (!raw) {
      return "";
    }

    if (raw.indexOf("/") === 0) {
      // 相对于根目录(/xxxx/xxx)
      return contextPath + raw;
    } else {
      // 绝对地址（http://xxx,https://xxx,ftp://xxx）
      // 相对地址(xxx/xxxx)
      return raw;
    }
  }

  //配置axios
  function axiosUrlIntercetpor(config) {
    config.url = fullUrl(config.url);
    return config;
  }

  function isShortUrl(url) {
    return !/^(http(s)?:)\/\//.test(url);
  }

  function toShortUrl(url) {
    return url.replace(/^(http(s)?:)\/\/[^//]+/, '');
  }

  function axiosLoginInterceptor(response) {
    if (response.data.errorCode === 401 && response.data.loginUrl) {
      //生成登录并跳回地址
      const loginUrl = response.data.loginUrl;
      const forward = isShortUrl(loginUrl) ? toShortUrl(window.top.location.href) : window.top.location.href;
      const redirect = new Url(loginUrl).setParam('fw', btoa(forward)).toString();
      //跳转到登录地址
      window.top.location.href = redirect;
      throw new Error(response.data.errorMsg);
    }
    return response;
  }

  axios.interceptors.request.use(axiosUrlIntercetpor);
  axios.interceptors.response.use(axiosLoginInterceptor);
  return axios;
})();*/
